package com.travel.recommend.strategyPattern;

import com.travel.common.to.AttractionInfoTo;
import com.travel.recommend.feign.SightFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 默认热门推荐
 */
@Slf4j
@Service
public class DefaultHotRecommendationStrategy implements RecommendationStrategy{
    @Autowired
    SightFeignService sightFeignService;

    @Override
    public List<Integer> recommend(Integer userId) {
        // 获取所有的景点，按评分降序推荐
        List<AttractionInfoTo> allAttraction = sightFeignService.getAllAttraction();
        List<Integer> collect = allAttraction.stream().sorted(Comparator.comparingDouble(AttractionInfoTo::getScore).reversed())
                .map(AttractionInfoTo::getAttractionId).collect(Collectors.toList());
        System.out.println("热门默认推荐 "+collect);

        return collect;
    }

    @Override
    public void initAlgorithmConfig() {

    }
}
